package cn.nbt.busManage.model.vo;

import cn.nbt.busManage.model.dto.MenuDto;
import cn.nbt.busManage.model.entity.Menu;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

@Data
public class MenuVo implements Serializable {
    private Integer id;
    private String name;
    private Integer pid;
    private String url;
    private List<MenuDto> children;

    public MenuVo(MenuDto menuDto){
        this.pid = menuDto.getPid();
        this.id = menuDto.getId();
        this.url = menuDto.getUrl();
        this.name = menuDto.getName();
        this.children = menuDto.getMenuDtos();
    }

    @JsonCreator
    public MenuVo(
            @JsonProperty("id") Integer id,
            @JsonProperty("name") String name,
            @JsonProperty("pid") Integer pid,
            @JsonProperty("url") String url
    ){
        this.pid = pid;
        this.id = id;
        this.name = name;
        this.url = url;
    }
}
